textiter: don't call g_utf8_prev_char() on start of string
authorSébastien Wilmet <swilmet@gnome.org>
Thu, 31 Jul 2014 12:11:49 +0000 (14:11 +0200)
committerSébastien Wilmet <swilmet@gnome.org>
Thu, 31 Jul 2014 16:00:49 +0000 (18:00 +0200)
Changes also the "goto finally" with a break. A break is more common.

Another way is to use g_utf8_find_prev_char().

https://bugzilla.gnome.org/show_bug.cgi?id=638709

gtk/gtktextiter.c

index 5a53581252d5bdd6100bff04bda126583cebce5b..53fe4dbd163e59a3cfd52dffd4dbc6f70d929a53 100644 (file)
@@ -4641,14 +4641,17 @@ utf8_strrcasestr (const gchar *haystack,
   p = g_utf8_offset_to_pointer (caseless_haystack, i);
   needle_len = strlen (needle);
 
-  while (p >= caseless_haystack)
+  while (TRUE)
     {
       if (exact_prefix_cmp (p, needle, needle_len))
         {
           ret = pointer_from_offset_skipping_decomp (haystack, i);
-          goto finally;
+          break;
         }
 
+      if (p == caseless_haystack)
+        break;
+
       p = g_utf8_prev_char (p);
       i--;
     }